import datetime
import time
from threading import Thread

import pickledb
import json
'''
API 地址
https://pythonhosted.org/pickleDB/commands.html

'''
def write():
    db = pickledb.load('ws.db', True)
    date = datetime.datetime.now().strftime('%Y-%m-%d')
    key = 'ws%s' % date
    for x in range(0,30):
        list_=db.lcreate(key) # 创建list
        print('添加前 :',db.lgetall(key))  # 获取所有列表
        num = range(0,36)
        db.ladd(key, num)
        print('添加后 :',db.lgetall(key))  # 获取所有列表
    print(1)
def pop():
    # db = pickledb.load('ws.db', True)
    # date = datetime.datetime.now().strftime('%Y-%m-%d')
    # key = 'ws%s' % date
    # for x in range(0,30):
    #     print('删除前 :',db.lgetall(key))  # 获取所有列表
    #     print(db.lpop(key,0))  # 取出并删除一个值
    #     print('删除后all:',db.lgetall(key))
    print(2)
# db.dump()


if __name__ == '__main__':
    t1 = Thread(target=write)
    t2 = Thread(target=pop)
    t1.start()
    time.sleep(1)
    t2.start()

    t1.join()
    t2.join()
